/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Action;

import Entity.TicketsSummary;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Cyrax
 */
@Stateless
public class TicketsSumSessionBean implements TicketsSumSessionBeanLocal {
    @PersistenceContext(unitName = "EasyTickets-ejbPU")
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }
    
    
    @Override
    public List<TicketsSummary> listAllTicketsSum()
    {
      List<TicketsSummary> tks;
         tks=em.createNamedQuery("TicketsSummary.findAll").getResultList();
      return tks;
    }
     @Override
    public List<TicketsSummary> searchTicketsSummary(String email) {
        List<TicketsSummary> ts = null;

        ts = em.createQuery("SELECT t FROM TicketsSummary t WHERE t.email like :email").setParameter("email", "%" + email + "%").getResultList();
        System.out.println("userName : " + email);


        return ts;
    }
}
